﻿#include<iostream>
using namespace std;
const int N = 100010;

int e[N], l[N], r[N], idx;

void init()
{
    //l[1]=0;
    r[0] = 1;
    l[1] = 0;
    idx = 2;
}
//将x插入在k右边
void add(int k, int x)
{
    e[idx] = x;

    r[idx] = r[k];
    l[idx] = k;//l[k];
    l[r[k]] = idx;
    r[k] = idx;//r[l[k]]=idx;

    idx++;
}

//删除k节点
void remove(int k)
{
    r[l[k]] = r[k];
    l[r[k]] = l[k];
}

int main()
{
    int m;
    cin >> m;
    init();
    string op;
    int k, x;
    while (m--)
    {
        cin >> op;
        if (op == "L")//最左边插，0右边插入
        {
            cin >> x;
            add(0, x);
        }
        else if (op == "R")//最右插，1左边插入
        {
            cin >> x;
            add(l[1], x);
        }
        else if (op == "D")
        {
            cin >> k;
            remove(k + 1);
        }
        else if (op == "IL")//k左边,l[k]右边
        {
            cin >> k >> x;
            add(l[k + 1], x);
        }
        else//(op=="IR")
        {
            cin >> k >> x;
            add(k + 1, x);
        }
    }
    for (int i = r[0]; i != 1; i = r[i])  cout << e[i] << " "; //i!=1
}

/*总结
1.l[idx] = k; 不是l[idx] =l[k];
2.r[k] = idx;不是r[l[k]]=idx;
3.for ()  i!=1  i=r[i]  */